import React from 'react'

type Props = {}

// 构建函数
class a1{
  title:string;
  constructor(title:string){
    this.title=title
  }
}
class a2 extends a1{
  age:number;
  constructor(title:string,age:number){
    super(title)
    this.age=age
  }
}
const b3=new a2("张三",11)

// 封装函数
type Difference=(a:number,b:number)=>number;
const difference:Difference=function(a,b){
  return a-b
}
console.log(difference(20,10));

// 排序
const arr=[1,3,4,5,2];
const arr1=arr.sort((a,b)=>a-b);
console.log(arr1)

// 最大差值
const str=[1,4,0,8,9,6];
const str1=str.sort();
const str2=str1[str1.length-1]-str1[0];
console.log(str2)

// 去重
const qc=new Set([1,1,2,2,3,3,4,4])
console.log(qc)

// 去重求和
const brr=(a:number[])=>{
  const un=Array.from(new Set(a))
  const sum=un.reduce((x,y)=>x+y,0)
  return sum
}
let num=[1,1,2,3,4,,4];
let arr2=brr(num)
console.log(arr2)

// 类
const lei=(a:string,b:number):boolean=>{
  return a.length>b
}
console.log(lei('lei',111))

// 封装
function fz(a:number,b:number){
  return a-b
}
console.log(fz(20,2))

const App = (props: Props) => {
  return (
    <div>App</div>
  )
}

export default App